home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
xlt86.zip
/
XLT86.ASM
< prev
next >
Wrap
Assembly Source File
|
1985-08-15
|
49KB
|
3,181 lines
;*******************************************************
page 60,132
;
; XLT86
;
; Translates Intel 8080 assembly language source code
; to Intel 8086 assembly language source code.
;
; 11/11/84 Frank J. Zerilli
;
; 8086 version, 11/20/84
;
;
; MS-DOS version 12/20/84
; by Craig Derouen
VERS EQU 110
;
;*******************************************************
;
; XLT86 processes lines with the exclamation point
; statement separator correctly. It strips trailing
; blanks or tabs from lines. It replaces initial
; asterisks in lines with semicolons. It provides
; several options to format the output file for best
; appearance.
;
; This program gives the choice of converting the
; case of instructions to upper or lower case or of
; trying to preserve the case of instructions.
;
; An activity dot is printed on the console for
; every 100 lines of input processed.
;
;
;
; Command line:
;
; XLT86 [d:]srcfile[.typ] [d:destfile.typ]
;
; All parameters in brackets are optional, and, if
; omitted, the default values are:
;
; Source file-type -- ASM
; Destination file-type -- A86
; Destination file-name -- same as the source file-name
; Drive -- current drive
;
; FLAG LOCATIONS:
;
; 103H -- Change to non-zero value to suppress
; translation of several non-standard opcodes:
; REQ, RNE, RLT, RGE, CEQ, CNE, CLT, CGE
; JEQ, JNE, JLT, JGE,
; ENT, NAM, RAM, ROG, IFC, ICL, LST, MAC
;
; 104H -- If non-zero (default) XLT86 converts lines
; with multiple statements separated by DR's EP
; separator into separate lines.
; Change to zero for output on a single line
; with the translated statements separated by
; EP.
;
; 107H-- If zero (default) XLT86 translates
;
; PUSH PSW POP PSW
;
; to
;
; LAHF POP AX
; PUSH AX SAHF
;
; Otherwise, the translation is
;
; LAHF POP AX
; XCHG AH,AL XCHG AH,AL
; PUSH AX SAHF
; XCHG AH,AL
;
; 108H-- If zero (default) XLT86 translates
;
; INX rp DCX rp
;
; to
;
; INC rp' DEC rp'
;
; Otherwise, the translation is
;
; PUSHF PUSHF
; INC rp' DEC rp'
; POPF POPF
;
; 109H-- If zero (default) XLT86 translates
;
; DAD rp
;
; to
;
; ADD BX,rp'
;
; Otherwise, the translation is
;
; PUSHF
; ADD BX,rp'
; POPF
;
N00 EQU 0
N01 EQU 1
;
N07 EQU 7
N09 EQU 9 ;tab every 8th col.
NF8 EQU 0F8H ;mod 8
;
LBUFLN EQU 80 ;line buffer length
OPBFLN EQU 5 ;opcode buffer length
MEMSIZ EQU 4 ;memory available in Kb
IBNUM EQU 4*MEMSIZ
OBNUM EQU 4*MEMSIZ
RECLEN EQU 128 ;
STCKLN EQU 128 ;stack size
IBFLEN EQU IBNUM*RECLEN
OBFLEN EQU OBNUM*RECLEN
;
CTRLC EQU 3
EOT EQU 4
BEL EQU 7
HT EQU 9
LF EQU 0AH
CR EQU 0DH
ESC EQU 1BH
QUOTE EQU 27H
;
code segment byte
assume cs:code,ds:code
ORG 005CH
DFCB1 DB 16 DUP(?)
DFCB2 DB 16 DUP(?)
;
FNLEN EQU 8
EOS EQU EOT ; replacement for exclamation pt
EOF EQU 1AH
NFF EQU 0FFH ;disk error return
;
; BDOS FUNCTIONS
;
nABT EQU 0
nCIN EQU 1
nCOUT EQU 2
nCDAV EQU 0BH
nOPEN EQU 0FH
nCLOSE EQU 10H
nDEL EQU 13H
nRDNR EQU 14H
nWRNR EQU 15H
nCREAT EQU 16H
nCDISK EQU 19H
nDMA EQU 1AH
;
;
;
ORG 100H
;
HERE_FIRST:
JMP START
;
; OPTION FLAGS
;
PSEFLG DB 0 ;(103H) 0 to translate non-
; standard opcodes
MLTLFL DB 0FFH ;(104H) 0 to put input line with
; exc. pt. to output on one line
TCASFL DB 0 ;(105H) 0 to preserve case
;
LCASFL DB 0 ;(106H) 0 for upper case if
; TCASFL not zero
PSWFL DB 0 ;(107H) non-zero to preserve 8080
; order of PSW registers on stack
INXFL DB 0 ;(108H) non-zero to preserve flags
; with INX and DCX translations
DADFL DB 0 ;(109H) non-zero to preserve flags
; with DAD translation
;
; BDOS Functions
;
BDOS:
INT 21H
RET
;
; RETURN TO MSDOS
;
ABORT: MOV AH,4ch
INT 21h
;
; HELP MESSAGE
;
HMSG1:
DB CR,LF
DB LF
DB 'XLT86 translates Intel 8080 assembly language source',CR,LF
DB 'code into Intel 8086 assembly language source code.',CR,LF
DB LF
DB 'It is invoked by a command of the form:',CR,LF
DB LF
DB ' XLT86 [d:]srcfile[.typ] [d:destfile.typ]',CR,LF
DB LF
DB 'The brackets denote optional parameters and the ',CR,LF
DB 'default values are:',CR,LF
DB LF
DB ' Source file-type -- ASM',CR,LF
DB ' Destination file-type -- A86',CR,LF
DB ' Destination file-name -- same as source file-name',CR,LF
DB ' Drive -- current drive',CR,LF
DB CR,LF
DB 'Press any key to continue - ',0
HMSG2:
DB CR,LF
DB LF
DB 'Examples:',CR,LF
DB LF
DB 'XLT86 PRGM1 --translates PRGM1.ASM to PRGM1.A86',CR,LF
DB 'XLT86 PRGM1 PRGM2 --translates PRGM1.ASM to PRGM2.A86',CR,LF
DB 'XLT86 PRGM1.TXT PRGM2.MAC --translates PRGM1.TXT to PRGM2.MAC',CR,LF
DB LF
DB 'XLT86 also has the following features:',CR,LF
DB LF
DB 'Case will be preserved as well as possible -- if an opcode has',CR,LF
DB 'a lower case character, the translated opcode will be in lower',CR,LF
DB 'case.',CR,LF
DB LF
DB 'All asterisks at the beginning of lines will be replaced with',CR,LF
DB 'semicolons.',CR,LF
DB LF
DB 'A dot is printed on the console for every 100 lines of input ',CR,LF
DB 'processed.',CR,LF
DB LF
DB 0
;
;=============================================================================
;
; Program begins here
;
START:
MOV AX,SS
MOV SSBDOS,AX
MOV SPBDOS,SP
MOV AX,CS
MOV SS,AX
MOV SP,OFFSET STACK
MOV AL,DFCB1+1 ; check for a file name
CMP AL,' ' ; print help if no name
JNZ BEGIN ; no help requested
MOV DX,OFFSET SIGNON
CALL PRTLIN
MOV DX,OFFSET HMSG1 ; print help message
CALL PRTLIN
MOV AH,nCIN ; wait for any character
CALL BDOS
MOV DX,OFFSET HMSG2 ; print rest of help
CALL PRTLIN
MOV AX,SSBDOS
MOV SS,AX ; retrieve system stack
MOV SP,SPBDOS ; pointer and pop
MOV al,2 ; put in an error code
MOV AH,4CH
INT 21H ; Return to DOS
BEGIN: CALL HELLO ;signon, open in & out files
NXTLIN: CALL GETLIN ;get line from input file to buf
CALL PROCLIN ; process line
JMP NXTLIN
;
;
;
;*******************************************************
;
; Print signon, open input
; and output files.
;
HELLO: MOV DX,OFFSET SIGNON
CALL PRTLIN
HELLO0: MOV AL,'D' ; translate DB & EQU (for
MOV OPTBDB,AL ; uniform formatting)
MOV MLTSPC,HT ; for opcodes xltd to mlt stmts
MOV AL,HT ; HT after opcode
MOV BX,OFFSET PUTHT+1
MOV [BX],AL
MOV AL,41 ; tab comments to col 33
MOV BX,OFFSET PUTND5+1
MOV [BX],AL
MOV AL,3CH ; CMP instruction
MOV BX,OFFSET EXCLAM
MOV [BX],AL
XOR AL,AL
MOV TCASFL,AL ; don't convert case
MOV LCASFL,AL ; lower case flag
MOV SEPMSG,OFFSET NEWLSP
MOV AL,PSEFLG ; translate non-standard
OR AL,AL ; opcodes ?
JZ LBL1
CALL NXPSD
LBL1:
MOV DX,OFFSET DBMSG
CALL PRTLIN ;
CALL CHKYES ; xlat DB & EQU ?
CMP AL,ESC
JNZ LBL2
JMP HELLO0
LBL2:
CMP AL,CTRLC
JNZ LBL3
JMP ABORT
LBL3:
CMP AL,'Y'
JZ LBL4
CALL NXDBEQ
LBL4:
MOV AL,MLTLFL ; force space after opcode
OR AL,AL ; if MLTLFL not set
JNZ LBL5
JMP HELLO2
LBL5:
MOV DX,OFFSET SPCMSG
CALL PRTLIN ; use space after
CALL CHKYES ; opcode ?
CMP AL,ESC
JNZ LBL6
JMP HELLO0
LBL6:
CMP AL,CTRLC
JNZ LBL7
JMP ABORT
LBL7:
CMP AL,'Y'
HELLO2: JNZ LBL8
CALL SETSPC
LBL8:
MOV DX,OFFSET COLMSG
CALL PRTLIN ;
CALL CHKYES ; start comment
CMP AL,ESC
JNZ LBL9
JMP HELLO0
LBL9:
CMP AL,CTRLC
JNZ LBL10
JMP ABORT
LBL10:
CMP AL,'Y'
JNZ LBL11
CALL SETCOL ; in column 25 ?
LBL11:
MOV DX,OFFSET EXCMSG
CALL PRTLIN ; Ignore exclamation point
CALL CHKYES ; separator ?
CMP AL,ESC
JNZ LBL12
JMP HELLO0
LBL12:
CMP AL,CTRLC
JNZ LBL13
JMP ABORT
LBL13:
CMP AL,'Y'
JNZ LBL14
CALL SETNEX
LBL14:
MOV DX,OFFSET MLTMSG
CALL PRTLIN ; multiple statements
CALL CHKYES ; on one line ?
CMP AL,ESC
JNZ LBL15
JMP HELLO0
LBL15:
CMP AL,CTRLC
JNZ LBL16
JMP ABORT
LBL16:
CMP AL,'Y'
JNZ LBL17
CALL SETMLT
LBL17: